import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HeaderComponent } from './components/header/header.component';
import { NewsComponent } from './components/news/news.component';
import { ListComponent } from './components/list/list.component';
import { NewdetailComponent } from './components/newdetail/newdetail.component';
import { IndexComponent } from './component/index/index.component';
import { SportComponent } from './component/index/sport/sport.component';
import { MusicComponent } from './component/index/music/music.component';
import { MusiclistComponent } from './component/musiclist/musiclist.component';
import { MusicdetailComponent } from './component/musiclist/musicdetail/musicdetail.component';
import { HomeComponent } from './component/home/home.component';
// 路由不能加斜杠
const routes: Routes = [
  {
    path: 'home',
    component: HeaderComponent
  },
  {
    path: 'new',
    component: NewsComponent
  },
  {
    path: 'list',
    component: ListComponent
  },
  // 这是get传值的路由 不需要设置id
  {
    path: 'newdetail',
    component: NewdetailComponent
  },
  {
    path: 'newdetail/:id',
    component: NewdetailComponent
  },
  {
    path: 'index',
    component: IndexComponent,
    children: [
      {
        path: 'sport',
        component: SportComponent
      },
      {
        path: 'music',
        component: MusicComponent
      }
    ]
  },
  {
    path: 'musiclist',
    component: MusiclistComponent
  },
  {
    path: 'musicdetail/:id',
    component: MusicdetailComponent,
  },
  {
    path: 'homes',
    component: HomeComponent,
  },
  {
    path: 'user',
    loadChildren: './module/user/user.module#UserModule'
  },
  {
    path: 'product',
    loadChildren: './module/product/product.module#ProductModule'
  },
  {
    path: 'article',
    loadChildren: './module/article/article.module#ArticleModule'
  },
  // 重定向
  // 要放最后
  {
    path: '**',
    redirectTo: 'homes',
    pathMatch: 'full'
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
